
const xpcom = require("xpcom");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function AboutWidgets () {}
AboutWidgets.prototype = {
    newChannel:     function (uri) {
        if (uri.spec != "about:widgets") return;
        var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
        // console.log("manager: " + packaging.getURLForData("/manager.xhtml"));
        var channel = ios.newChannel(packaging.getURLForData("/manager.xhtml"), null, null);
        channel.originalURI = uri;
        return channel;
    },

    getURIFlags:    function (uri) {
        return Ci.nsIAboutModule.ALLOW_SCRIPT;
    },

    classDescription:   "About Widgets",
    classID:            Components.ID("0f1a4f3e-0261-4422-8ec5-1b0e89de4bc4"),
    contractID:         "@mozilla.org/network/protocol/about;1?what=widgets",
    QueryInterface:     XPCOMUtils.generateQI([Ci.nsIAboutModule])
};

xpcom.register({
    create:     AboutWidgets,
    name:       AboutWidgets.prototype.classDescription,
    contractID: AboutWidgets.prototype.contractID,
    uuid:       AboutWidgets.prototype.classID
});
